package qldc.pm.tienan.searchcontainer.util.nguoicanxoaantich;

import qldc.pm.tienan.dto.DS_NguoiTienAnDTO;

import com.liferay.portal.kernel.util.OrderByComparator;

public class NgayToaAnDoiTuongTienAnCanXoaAnTichComparator extends OrderByComparator {
	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	private final boolean _asc;

	public static String ORDER_BY_ASC = "ngayToaAn ASC";
	public static String ORDER_BY_DESC = "ngayToaAn DESC";

	public NgayToaAnDoiTuongTienAnCanXoaAnTichComparator() {
		this(false);
	}

	public NgayToaAnDoiTuongTienAnCanXoaAnTichComparator(boolean orderByAsc) {
		_asc = orderByAsc;
	}

	@Override
	public int compare(Object obj1, Object obj2) {
		DS_NguoiTienAnDTO doiTuongTienAn1 = (DS_NguoiTienAnDTO) obj1;
		DS_NguoiTienAnDTO doiTuongTienAn2 = (DS_NguoiTienAnDTO) obj2;

		int value = doiTuongTienAn1.getNgayToaAnMoiNhat().compareTo(doiTuongTienAn2.getNgayToaAnMoiNhat());

		if (this.equals(_asc)) {
			return value;
		} else {
			return -value;
		}
	}

	public String getOrderBy(){
		if (_asc) {
			return ORDER_BY_ASC;
		} else {
			return ORDER_BY_DESC;
		}
	}
}
